package com.wg.java;

import com.wg.java.model.Student;
import com.wg.java.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

@SpringBootApplication
public class DemoApplication implements CommandLineRunner {
    @Autowired
    private StudentService studentService;

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }

    //第一种方式不能在静态方法里面访问studentService
//	public static void sad(){
//		studentService.sayHello();
//	}
	@Override
    public void run(String... args) throws Exception {
        Student student = studentService.sayHello();
        System.out.println(student.getAge());
    }
//    自己写一个非静态方法也不行  不能执行
	public void run2(String... args) throws Exception {
		Student student = studentService.sayHello();
		System.out.println(student.getAge());
	}
}
